package com.example.spareparts.repository;

import com.example.spareparts.entity.Supplier;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SupplierRepository  {
      @Select("SELECT * FROM Suppliers")
      List<Supplier> findAllSupplier();
      @Insert("INSERT INTO Suppliers (name, contact_people,contact_phone) VALUES (#{name}, #{contactPeople},#{contactPhone})")
      @Options(useGeneratedKeys = true, keyProperty = "supplierid")
      void insertSupplier(Supplier supplier);
      @Update("UPDATE Suppliers SET name= #{name}, contact_people= #{contactPeople},contact_phone=#{contactPhone} WHERE supplier_id= #{supplierid}")
      void updateSupplier(Supplier supplier);


      @Delete("DELETE FROM Suppliers WHERE supplier_id= #{supplierid}")
      void deleteSupplier(Long supplierid);
      @Select("SELECT * FROM Suppliers WHERE supplier_id= #{supplierid}")
      Supplier findSupplierById(Long supplierid);
}